﻿using System.Collections.Generic;
using DapperExtensions.Mapper;
using Newtonsoft.Json;

namespace ZilLion.Service.WeChatMall.Domain.Entitys.Orders
{
    public class DiscountResultDto
    {
        [JsonProperty("products")]
        public IList<ProductDiscountResultEntity> ProductDiscountResult { get; set; } =
            new List<ProductDiscountResultEntity>();

        [JsonProperty("bill")]
        public DiscountResultEntity DiscountResultEntity { get; set; }
    }

    public class ProductDiscountResultEntity
    {
        /// <summary>
        ///     货品ID
        /// </summary>

        [JsonProperty("foodId")]
        public long Hpid { get; set; }

        /// <summary>
        ///     成交小计
        /// </summary>
        [JsonProperty("summy")]
        public decimal Cjxj { get; set; }
    }

    public class ProductDiscountResultEntityMapper : ClassMapper<ProductDiscountResultEntity>
    {
        public ProductDiscountResultEntityMapper()
        {
            Table("#hpcjxj");
            Map(f => f.Hpid).Column("hpid");
            Map(f => f.Cjxj).Column("cjxj");
        }
    }

    public class DiscountResultEntity
    {
        /// <summary>
        ///     折后金额
        /// </summary>
        public decimal SumAmount { get; set; }

        /// <summary>
        ///     获得积分
        /// </summary>
        public decimal SumIntegral { get; set; }
    }

    public class DiscountResultEntityMapper : ClassMapper<DiscountResultEntity>
    {
        public DiscountResultEntityMapper()
        {
            Table("#cj");
            Map(f => f.SumAmount).Column("cjje");
            Map(f => f.SumIntegral).Column("jf");
        }
    }
}